import React, { Component } from "react";
import { Card, Button, Table } from "antd";
import LinkButton from "../../../components/link-button";

//单选全选
const rowSelection = {
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(
      `selectedRowKeys: ${selectedRowKeys}`,
      "selectedRows: ",
      selectedRows
    );
  },
  getCheckboxProps: (record) => ({
    disabled: record.name === "Disabled User", // Column configuration not to be checked
    name: record.name,
  }),
};
class strategicHome extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    const columns = [
      {
        title: "功能名称",
        dataIndex: "name",
        render: (text) => (
          <LinkButton
            onClick={() =>
              this.props.history.push("/strategic/detail", { text })
            }
          >
            {text}
          </LinkButton>
        ),
      },
      {
        title: "策略总数",
        dataIndex: "age",
      },
      {
        title: "紧急",
        dataIndex: "sos",
      },
      {
        title: "高",
        dataIndex: "tall",
        //text是值，record是当前项对象，index是下标
        render: (text) => <span style={{ color: "red" }}>{text}</span>,
      },
      {
        title: "中",
        dataIndex: "centre",
        render: (text) => <span style={{ color: "orange" }}>{text}</span>,
      },
      {
        title: "低",
        dataIndex: "low",
        render: (text) => <span style={{ color: "blue" }}>{text}</span>,
      },
      {
        title: "信息",
        dataIndex: "message",
        render: (text) => <span style={{ color: "green" }}>{text}</span>,
      },
      {
        title: "策略组描述",
        dataIndex: "desc",
      },
    ];

    const data = [
      {
        key: "1",
        name: "快速扫描",
        age: 32,
        sos: "3848",
        tall: "21",
        centre: "12",
        low: "54",
        message: "15",
        desc: "10",
      },
      {
        key: "2",
        name: "完全扫描",
        age: 42,
        sos: "8009",
        tall: "21",
        centre: "12",
        low: "54",
        message: "15",
        desc: "10",
      },
      {
        key: "3",
        name: "window扫描",
        age: 32,
        sos: "2815",
        tall: "21",
        centre: "12",
        low: "54",
        message: "15",
        desc: "10",
      },
      {
        key: "4",
        name: "大数据扫描",
        age: 99,
        sos: "1196",
        tall: "21",
        centre: "12",
        low: "54",
        message: "15",
        desc: "10",
      },
      {
        key: "5",
        name: "大数据扫描",
        age: 99,
        sos: "1196",
        tall: "21",
        centre: "12",
        low: "54",
        message: "15",
        desc: "10",
      },
      {
        key: "6",
        name: "大数据扫描",
        age: 99,
        sos: "1196",
        tall: "21",
        centre: "12",
        low: "54",
        message: "15",
        desc: "10",
      },
    ];
    return (
      <Card style={{ width: "100%" }}>
        <div>
          <Button>新建策略</Button>
          <Table
            rowSelection={rowSelection}
            columns={columns}
            dataSource={data}
            pagination={{ defaultPageSize: 5 }}
          />
        </div>
      </Card>
    );
  }
}

export default strategicHome;
